﻿using UnityEngine;
using System.Collections;

public class ComposeChildren : MonoBehaviour 
{
	public HumanProperty Human1;
	public HumanProperty Human2;
	public GameObject HumanPrefab;
	public HumanProperty ResultHuman;

	public void MakeChildren()
	{
		//NGUITools.AddChild (this.gameObject, HumanPrefab);

		ResultHuman.gameObject.SetActive (true);
		ResultHuman.BodyWidth = Average (Human1.BodyWidth, Human2.BodyWidth);
		ResultHuman.BodyHeight = Average (Human1.BodyHeight, Human2.BodyHeight);
		ResultHuman.HeadWidth = Average (Human1.HeadWidth, Human2.HeadWidth);
		ResultHuman.HeadHeight = Average (Human1.HeadHeight, Human2.HeadHeight);
		ResultHuman.HandLength = Average (Human1.HandLength, Human2.HandLength);
		ResultHuman.LegLength = Average (Human1.LegLength, Human2.LegLength);
		ResultHuman.SkinColor = Color.Lerp (Human1.SkinColor, Human2.SkinColor, 0.5f);


		ResultHuman.UpdateShow ();
	}

	private int Average(int value1, int value2)
	{
		return (value1 + value2) / 2;
	}
}
